Skip to content

Speed up multi-ROI deletion in the GUI#1420

Open
chenyenchung wants to merge 1 commit intoMouseLand:mainfrom
chenyenchung:fast-multi-delete
Open

Speed up multi-ROI deletion in the GUI#1420
chenyenchung wants to merge 1 commit intoMouseLand:mainfrom
chenyenchung:fast-multi-delete

Conversation

@chenyenchung
Copy link
Copy Markdown

This a proof-of-concept change associated with #1419 .

  • Add batch deletion utilities in cellpose/gui/delete_utils.py to normalize ROI IDs and relabel masks in a single pass.
  • Update cellpose/gui/gui.py so multi-ROI deletion uses the batch path, while single-ROI deletion remains the same.
  • Preserve existing GUI-side effects, including ROI count updates, saved-set updates, and deletion tracking.
  • Add regression tests in tests/test_gui_delete_utils.py to verify that the batch path behaves in the same way as the original deletion behavior in both 2D and 3D cases.
  • Treat invalid or duplicate ROI IDs as no-ops.

Testing

  • Added a fixed-case regression test.
  • Added randomized 2D and 3D equivalence tests against the legacy deletion path.
  • Added a no-op test for invalid ROI IDs.

Comment on lines +90 to +869
r = np.array(
[
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60,
64,
68,
72,
76,
80,
84,
88,
92,
96,
100,
104,
108,
112,
116,
120,
124,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
128,
120,
112,
104,
96,
88,
80,
72,
64,
56,
48,
40,
32,
24,
16,
8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
7,
11,
15,
19,
23,
27,
31,
35,
39,
43,
47,
51,
55,
59,
63,
67,
71,
75,
79,
83,
87,
91,
95,
99,
103,
107,
111,
115,
119,
123,
127,
131,
135,
139,
143,
147,
151,
155,
159,
163,
167,
171,
175,
179,
183,
187,
191,
195,
199,
203,
207,
211,
215,
219,
223,
227,
231,
235,
239,
243,
247,
251,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
]
)
g = np.array(
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
9,
9,
8,
8,
7,
7,
6,
6,
5,
5,
5,
4,
4,
3,
3,
2,
2,
1,
1,
0,
0,
0,
7,
15,
23,
31,
39,
47,
55,
63,
71,
79,
87,
95,
103,
111,
119,
127,
135,
143,
151,
159,
167,
175,
183,
191,
199,
207,
215,
223,
231,
239,
247,
255,
247,
239,
231,
223,
215,
207,
199,
191,
183,
175,
167,
159,
151,
143,
135,
128,
129,
131,
132,
134,
135,
137,
139,
140,
142,
143,
145,
147,
148,
150,
151,
153,
154,
156,
158,
159,
161,
162,
164,
166,
167,
169,
170,
172,
174,
175,
177,
178,
180,
181,
183,
185,
186,
188,
189,
191,
193,
194,
196,
197,
199,
201,
202,
204,
205,
207,
208,
210,
212,
213,
215,
216,
218,
220,
221,
223,
224,
226,
228,
229,
231,
232,
234,
235,
237,
239,
240,
242,
243,
245,
247,
248,
250,
251,
253,
255,
251,
247,
243,
239,
235,
231,
227,
223,
219,
215,
211,
207,
203,
199,
195,
191,
187,
183,
179,
175,
171,
167,
163,
159,
155,
151,
147,
143,
139,
135,
131,
127,
123,
119,
115,
111,
107,
103,
99,
95,
91,
87,
83,
79,
75,
71,
67,
63,
59,
55,
51,
47,
43,
39,
35,
31,
27,
23,
19,
15,
11,
7,
3,
0,
8,
16,
24,
32,
41,
49,
57,
65,
74,
82,
90,
98,
106,
115,
123,
131,
139,
148,
156,
164,
172,
180,
189,
197,
205,
213,
222,
230,
238,
246,
254,
]
)
b = np.array(
[
0,
7,
15,
23,
31,
39,
47,
55,
63,
71,
79,
87,
95,
103,
111,
119,
127,
135,
143,
151,
159,
167,
175,
183,
191,
199,
207,
215,
223,
231,
239,
247,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
251,
247,
243,
239,
235,
231,
227,
223,
219,
215,
211,
207,
203,
199,
195,
191,
187,
183,
179,
175,
171,
167,
163,
159,
155,
151,
147,
143,
139,
135,
131,
128,
126,
124,
122,
120,
118,
116,
114,
112,
110,
108,
106,
104,
102,
100,
98,
96,
94,
92,
90,
88,
86,
84,
82,
80,
78,
76,
74,
72,
70,
68,
66,
64,
62,
60,
58,
56,
54,
52,
50,
48,
46,
44,
42,
40,
38,
36,
34,
32,
30,
28,
26,
24,
22,
20,
18,
16,
14,
12,
10,
8,
6,
4,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
8,
16,
24,
32,
41,
49,
57,
65,
74,
82,
90,
98,
106,
115,
123,
131,
139,
148,
156,
164,
172,
180,
189,
197,
205,
213,
222,
230,
238,
246,
254,
]
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenyenchung please undo the formatter-related changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies for the noise. I should have disabled my auto-formatter. I’ve rebased and force-pushed to revert those changes and keep the diff focused on the actual logic. Ready for review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants